package com.yangyouli.unity_demo_server.util;

import java.util.Arrays;

public class ArrayUtil {
	/**
	 * 合并对象类型的数组
	 * @param first
	 * @param second
	 * @return
	 */
	public static <T> T[] concat(T[] first, T[] second) {
		T[] result = Arrays.copyOf(first, first.length + second.length);
		System.arraycopy(second, 0, result, first.length, second.length);
		return result;
	}
	
	/**
	 * 合并两个为基本数据类型 byte 的数组
	 * @param first
	 * @param second
	 * @return
	 */
	public static byte[] concat(byte[] first, byte[] second) {
		byte[] result = Arrays.copyOf(first, first.length + second.length);
		System.arraycopy(second, 0, result, first.length, second.length);
		return result;
	}
	
	/**
	 * 合并两个为基本数据类型 int 的数组
	 * @param first
	 * @param second
	 * @return
	 */
	public static int[] concat(int[] first, int[] second) {
		int[] result = Arrays.copyOf(first, first.length + second.length);
		System.arraycopy(second, 0, result, first.length, second.length);
		return result;
	}
}
